package com.whu.aircraft;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ControlCommand {
    //方向 距离 悬停
    private byte direction;//
    private float distance;
    private byte state;

    public byte[] command2bytes(){
        ByteBuf buf = Unpooled.buffer();
        buf.writeByte(this.direction);
        buf.writeFloat(this.distance);
        buf.writeByte(this.state);
        byte[] bytes = new byte[buf.readableBytes()];
        buf.readBytes(bytes);
        buf.release();//释放buf
        return bytes;
    }
}
